import { ModalProps } from "antd"
import React from "react"

import { useLocale } from "@/locales"

import { BreakLine, ModalStyle } from "./index.styled"

const CommonModal: React.FC<ModalProps> = ({ title, onOk, open = false, onCancel, children, cancelText, okText, ...props }) => {
	const { formatMessage } = useLocale()

	return (
		<>
			<ModalStyle
				title={title}
				open={open}
				onOk={onOk}
				onCancel={onCancel}
				cancelText={cancelText || formatMessage({ id: "common.button.cancel" })}
				okText={okText || formatMessage({ id: "common.button.confirm" })}
				{...props}
			>
				{title && <BreakLine />}
				{children}
			</ModalStyle>
		</>
	)
}

export default CommonModal
